package com.itqf.controller;

import com.itqf.entity.User;
import com.itqf.utils.R;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/10/12
 * @Time: 上午11:18
 */
@RestController
@CrossOrigin("*")//http://localhost:8020  允许http://localhost:8082跨域访问
public class MyRestController {

   // @RequestMapping(value = "/user/{id}",method = RequestMethod.GET)
    //localhost:8080/user/1
    @GetMapping("/user/{id}")
    public User findById(@PathVariable("id") int id){
        System.out.println("查");
        User u = new User();
        u.setId(id);
        u.setName("张总");
        u.setBirthdate(new Date());
        return u;
    }
    @DeleteMapping("/user/{id}")
    public R deleteById(@PathVariable("id") int id){
        System.out.println("删除"+id);

        return R.ok();
    }

    @PutMapping("/user")
    public R updateById(@RequestBody User user){
        System.out.println("修改"+user);

        return R.ok();
    }

    @PostMapping("/user")
    public R add(@RequestBody User user){
        System.out.println("新增"+user);

        return R.ok();
    }



}
